﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SimhoppKjellsFavoriterVT13
{
    public partial class InputContestant : Form
    {
        private string name;
        private DateTime birthDate;
        private Gender g;
        private string nationality;

        public InputContestant()
        {
            InitializeComponent();
        }

        private void InputContestant_Load(object sender, EventArgs e)
        {

        }

        private void okBtn_Click(object sender, EventArgs e)
        {
            //save data
            name = nameInputBox.ToString();
            birthDate = birthdateInputBox.Value.Date;
            //int ID;
            if (genderBtnFemale.Checked)
            {
                g = Gender.female;
            }
            else if (genderBtnMale.Checked)
            {
                g = Gender.male;
            }
            else
            {
                g = Gender.unspecified;
            }
            nationality = nationalityInputBox.ToString();

            Program.contestWindow.addContestant(name, birthDate, g, nationality, Program.contestWindow.nextID);

            //go back to contestwindow
            Program.contestWindow.Location = Program.contestInfoFrame.Location;
            this.Hide();
            Program.contestWindow.Show();
            
        }

        private void cancelBtn_Click(object sender, EventArgs e)
        {
            //discard data
            nameInputBox.ResetText();
            birthdateInputBox.ResetText();
            nationalityInputBox.ResetText();
            genderBtnFemale.ResetText();
            genderBtnMale.ResetText();
            genderBtnUnspecified.ResetText();

            //go back to contestwindow
            Program.contestWindow.Location = Program.contestInfoFrame.Location;
            this.Hide();
            Program.contestWindow.Show();

        }

        private void nextBtn_Click(object sender, EventArgs e)
        {
            name = nameInputBox.ToString();
            birthDate = birthdateInputBox.Value.Date;
            //int ID;
            if (genderBtnFemale.Checked)
            {
                g = Gender.female;
            }
            else if (genderBtnMale.Checked)
            {
                g = Gender.male;
            }
            else
            {
                g = Gender.unspecified;
            }
            nationality = nationalityInputBox.ToString();

            Program.contestWindow.addContestant(name, birthDate, g, nationality, 0);

            //emtpy fields
            nameInputBox.ResetText();
            birthdateInputBox.ResetText();
            nationalityInputBox.ResetText();
            genderBtnFemale.ResetText();
            genderBtnMale.ResetText();
            genderBtnUnspecified.ResetText();
            
        }

    }
}
